﻿using Microsoft.Practices.Prism.StoreApps;
using Microsoft.Xaml.Interactivity;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Codeplex.PrismAdapter
{
    /// <summary>
    /// ViewModelLocator.SetAutoWireViewModel(true);
    /// </summary>
    public class ViewModelLocatorBehavior : DependencyObject, IBehavior
    {
        private DependencyObject associatedObject;

        public DependencyObject AssociatedObject
        {
            get { return this.associatedObject; }
        }

        public void Attach(DependencyObject associatedObject)
        {
            this.associatedObject = associatedObject;
            ViewModelLocator.SetAutoWireViewModel(this.AssociatedObject, true);
        }

        public void Detach()
        {
        }
    }
}
